package com.ruoyi.system.controller.front;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.controller.CxBase;
import com.ruoyi.system.domain.StudentInfo;
import com.ruoyi.system.domain.front.CaseInfoInsertFront;
import com.ruoyi.system.domain.front.CaseinfoFront;
import com.ruoyi.system.service.front.ICaseFrontService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 案件信息Controller
 *
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/front/casefront")
public class CaseFrontController extends CxBase {
    @Autowired
    private ICaseFrontService caseFrontService;

    /**
     * 查询报警历史列表
     */
    @GetMapping("/casehistoryfrontlist")
    public TableDataInfo selectCaseHistoryFrontList(StudentInfo studentInfo)
    {
        logput(studentInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(caseFrontService.selectCaseHistoryFrontList(studentInfo));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }

    /**
     * 查询报警详细信息
     */
    @PostMapping("/casefrontinfo")
    public TableDataInfo casefrontinfo(@RequestBody CaseinfoFront caseinfoFront)
    {
        logput(caseinfoFront,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(caseFrontService.caseinfoFront(caseinfoFront));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }

    /**
     * 添加报警信息
     */
    @Transactional
    @Log(title = "报警信息", businessType = BusinessType.INSERT)
    @PostMapping("/insertCaseFront")
    public AjaxResult insertCaseFront(@RequestBody CaseInfoInsertFront caseinfoFront)
    {
        logput(caseinfoFront,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return toAjax(caseFrontService.insertCaseFront(caseinfoFront));
    }

    /**
     * 更新报警信息
     */
    @Transactional
    @Log(title = "报警信息", businessType = BusinessType.UPDATE)
    @PostMapping("/updateCaseFront")
    public AjaxResult updateCaseFront(@RequestBody CaseInfoInsertFront caseInfoInsertFront)
    {
        logput(caseInfoInsertFront,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return toAjax(caseFrontService.updateCaseFront(caseInfoInsertFront));
    }
}
